﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BugAdmin.Core.Extension
{
    public static class CorsExt
    {
        /// <summary>
        /// 添加跨域服务
        /// </summary>
        /// <param name="services"></param>
        public static void AddCorsExt(this IServiceCollection services)
        {
            services.AddCors(option =>
            {
                option.AddPolicy("allcors", corsBuilder =>
                {
                    corsBuilder.AllowAnyHeader().AllowAnyOrigin().AllowAnyMethod();
                });
            });
        }
        public static void UseCorsExt(this WebApplication app)
        {
            app.UseCors("allcors");
        }
    }
}
